import { AntdModalProps } from "@/hooks/useAntdModal"
import useQuery from "@/hooks/useQuery"
import { saveGatewayResource } from "@/service/deliver"
import { Form, Input, Modal } from "antd"
import EnvSelect from "./EnvSelect"


const SaveResource = ({ form, modalProps,confirmLoading, closeModal, refresh }: AntdModalProps) => {
  const query = useQuery()
  const onOk = async () => {
    let data = await form.validateFields()
    confirmLoading(true)
    await saveGatewayResource(data)
    confirmLoading(false)

    refresh()
    closeModal()
  }
  return <Modal  {...modalProps} onOk={onOk}>
    <Form labelCol={{ span: 5 }} form={form} initialValues={{
      group:'fe-gateway-html'
    }}>
      <Form.Item hidden name='id' >
        <Input />
      </Form.Item>
      <Form.Item label="环境"   name='env' rules={[{
        required: true,
        message: '域名'
      }]}>
       <EnvSelect />
      </Form.Item>
      <Form.Item label="标题" name='title' rules={[{
        required: true,
        message: '域名'
      }]}>
        <Input />
      </Form.Item>
      <Form.Item  name='dataId' label='Data ID' rules={[{
        required: true,
        message: 'Data ID'
      }]} >
        <Input />
      </Form.Item>
      
      <Form.Item label="Group" name='group' rules={[{
        required: true,
        message: '域名'
      }]}>
        <Input disabled/>
      </Form.Item>
     
     <Form.Item label='内容' name='content'>
      <Input.TextArea rows={10}/>
     </Form.Item>
      


    </Form>
  </Modal>
}
export default SaveResource